<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="用户账号:" prop="userNo">
        <el-input v-model="queryParams.userNo" placeholder="请输入用户账号" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="邮箱:" prop="mail">
        <el-input v-model="queryParams.mail" placeholder="请输入邮箱账号" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="状态:" prop="status">
        <el-select v-model="queryParams.status" clearable placeholder="请选择">
          <el-option label="正常" value="YES" />
          <el-option label="冻结" value="NO" />
        </el-select>
      </el-form-item>
      <el-form-item label="注册时间:" prop="date">
        <el-date-picker v-model="queryParams.date" type="daterange" clearable placeholder="日期区间选择" format="YYYY-MM-DD"
          value-format="YYYY-MM-DD" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- :header-cell-style="{ 'text-align': 'center' }" -->
    <el-table v-loading="loading" :data="userList">
      <el-table-column label="账号ID" prop="userNo" min-width="100px" align="center" />
      <el-table-column label="邮箱" align="left" prop="mail" min-width="200px" show-overflow-tooltip />
      <el-table-column label="代理商" align="center">
        <template #default="scope">
          <div v-if="scope.row.agentVO != null">{{ scope.row.agentVO.nickName }}</div>
        </template>
      </el-table-column>
      <el-table-column label="推荐人" align="center" min-width="100px" show-overflow-tooltip>
        <template #default="scope">
          <div v-if="scope.row.invitedId != ''">{{ scope.row.refereeVO ? scope.row.refereeVO.mail : '' }}</div>
          <div v-else>没有推荐人</div>
        </template>
      </el-table-column>
      <el-table-column label="账户余额" align="center" prop="walletVO.balance" min-width="80px" />
      <el-table-column label="钱包信息" align="left" show-overflow-tooltip min-width="140px">
        <template #default="scope">
          <div style="font-size: 12px">
            <div style="color: #1890FF; width: auto;">BTC : {{ scope.row.walletVO.btc || 0 }}</div>
            <div style="color: #1890FF; width: auto;">ETH : {{ scope.row.walletVO.eth || 0 }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="账号状态" align="center" prop="status">
        <template #default="scope">
          <div v-if="scope.row.status === 'Y'" style="color: rgba(14, 161, 82, 0.647058823529412)">
            {{ scope.row.statusLabel }}
          </div>
          <div v-if="scope.row.status === 'N'" style="color: rgba(217, 0, 27, 0.647058823529412)">
            {{ scope.row.statusLabel }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="是否在线" width="80px" align="center" prop="status">
        <template #default="scope">
          <div style="font-size: 12px">
            <div v-if="scope.row.onine == false" style="color: #1890FF; width: auto;">离线</div>
            <div v-else style="color: #1890FF; width: auto;">在线</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="风控" width="80px" align="center" prop="status">
        <template #default="scope">
          <div style="font-size: 12px">
            <div v-if="scope.row.risk == 0" style="color: #1890FF; width: auto;">安全</div>
            <div v-else-if="scope.row.risk == 1" style="color: #1890FF; width: auto;">正常</div>
            <div v-else-if="scope.row.risk == -1" style="color: #1890FF; width: auto;">风险</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="注册时间" align="center" prop="createTime" min-width="160px" />

      <el-table-column label="登录信息" width="150px" align="left" prop="status">
        <template #default="scope">
          <div style="font-size: 12px">
            <div v-if="scope.row.loginVO != null" style="color: #1890FF; width: auto;">{{ scope.row.loginVO.ipAddr }}
            </div>
            <div v-if="scope.row.loginVO != null" style="color: #1890FF; width: auto;">{{ scope.row.loginVO.loginTime }}
            </div>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column label="总充值" width="150px" align="center">
        <template #default="scope">
          <el-button type="primary" @click="handlerecharge('rechargeCount')">0</el-button>
        </template>
      </el-table-column>
      <el-table-column label="总提现" width="150px" align="center">
        <template #default="scope">
          <el-button type="primary" @click="handlerecharge('withdrawCount')">0</el-button>
        </template>
      </el-table-column> -->
      <el-table-column label="统计" width="150px" align="left">
        <template #default="scope">
          <div v-if="checkPermi(['wallet:chatUser:edit'])">
            <div><span style="font-size: 12px;color: #1890FF; width: auto;" @click="handlerecharge('rechargeCount')"
                v-hasPermi="['wallet:chatUser:edit']">总充值：{{ scope.row.rechargeSum }}</span></div>
            <div style="margin-top: 10px;font-size: 12px;color: #1890FF; width: auto;"><span
                @click="handlerecharge('withdrawCount')" v-hasPermi="['wallet:chatUser:edit']">总提现：{{ scope.row.cashSum
                }}</span></div>
          </div>
          <div v-else>
            <div><span style="font-size: 12px;color: #1890FF; width: auto;">总充值：{{ scope.row.rechargeSum }}</span></div>
            <div style="margin-top: 10px;font-size: 12px;color: #1890FF; width: auto;"><span>总提现：{{ scope.row.cashSum
                }}</span></div>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column label="提现控制" width="150px" align="center">
        <template #default="scope">
          <el-switch v-model="scope.row.isCash" active-color="#13ce66" inactive-color="#ff4949">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="交易控制" width="150px" align="center">
        <template #default="scope">
          <el-switch v-model="scope.row.isMarket" active-color="#13ce66" inactive-color="#ff4949">
          </el-switch>
        </template>
      </el-table-column> -->
      <el-table-column fixed="right" label="操作" width="230" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="danger" @click="handleStatus(scope.row)" v-hasPermi="['system:chatUser:edit']"
            size="small">
            {{ scope.row.status === 'Y' ? '冻结' : '解冻' }}
          </el-button>
          <el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['wallet:chatUser:edit']"
            size="small">
            修改
          </el-button>
          <!--          <el-button link type="primary" @click="handleUpScore(scope.row)"-->
          <!--                     v-hasPermi="['wallet:walletRechargeCash:up']">-->
          <!--            上分-->
          <!--          </el-button>-->
          <!--          <el-button link type="primary" @click="handleDownScore(scope.row)"-->
          <!--                     v-hasPermi="['wallet:walletRechargeCash:down']">-->
          <!--            下分-->
          <!--          </el-button>-->
          <el-button size="small" link type="primary" @click="viewDetail(scope.row)">
            详情
          </el-button>

          <el-dropdown style="padding-left: 12px;" size="small"
            @command="(command) => handleCommand(command, scope.row)"
            v-hasPermi="['system:walletRechargeCash:up', 'system:walletRechargeCash:down']">
            <el-button size="small" type="text" icon="d-arrow-right">
              更多</el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item command="handleUpScore" icon="key"
                  v-hasPermi="['system:walletRechargeCash:up']">上分</el-dropdown-item>
                <el-dropdown-item command="handleDownScore" icon="circle-check"
                  v-hasPermi="['system:walletRechargeCash:down']">下分</el-dropdown-item>
                <el-dropdown-item command="handlfx" icon="aim"
                  v-hasPermi="['system:walletRechargeCash:down']">风险</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.current" v-model:limit="queryParams.size"
      @pagination="pageChange" />

    <!-- 添加或修改用户管理对话框 -->
    <el-dialog :title="title" v-model="open" width="600px" append-to-body>
      <el-form ref="userRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="账号" prop="mail">
          <el-input v-model="form.mail" placeholder="请输入邮箱" />
        </el-form-item>
        <el-form-item label="昵称" prop="nickName">
          <el-input v-model="form.nickName" placeholder="请输入昵称" />
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="账号密码" prop="password">
          <el-input v-model="form.password" placeholder="请输入密码" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 上分/下分 对话框 -->
    <el-dialog :title="upDownTitle" v-model="upDownOpen" append-to-body>
      <el-form ref="upDownRef" :model="upDownForm" :rules="upDownRules" label-width="150px">
        <el-form-item v-if="upDownTitle === '风险'" label="操作账户：" prop="risk" required>
          <el-select @change="selHandleChannel" style="width: 500px" v-model="upDownForm.risk" clearable
            placeholder="请选择">
            <!-- <el-option label="USDT" value="USDT" />
            <el-option label="BTC" value="BTC" />
            <el-option label="ETH" value="ETH" /> -->
            <el-option v-for="item in optiones" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="upDownTitle != '风险'" label="操作账户：" prop="channel" required>
          <el-select style="width: 500px" v-model="upDownForm.channel" clearable placeholder="请选择">
            <!-- <el-option label="USDT" value="USDT" />
            <el-option label="BTC" value="BTC" />
            <el-option label="ETH" value="ETH" /> -->
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="upDownTitle != '风险'" label="操作额度：" prop="amount" required>
          <el-input v-if="upDownTitle === '下分'" v-model="upDownForm.amount"
            :placeholder="'可用额度：' + downBalance.toString()" style="width: 500px">
            <template #suffix>
              <el-button type="primary" @click="allDownScore" link>全部</el-button>
            </template>
          </el-input>
          <el-input v-else v-model="upDownForm.amount" placeholder="请输入" style="width: 500px" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="upDownConSubmit">确 定</el-button>
          <el-button @click="upDownOpen = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 总充值|总提现对话框 -->
    <el-dialog :title="rechargeTitle" v-model="openrecharge" append-to-body>
      <el-form :model="rechargeForm">
        <el-form-item v-if="rechargeTitle == 'rechargeCount'" :label="rechargeTitle" prop="rechargeCount" required>
          <el-input v-model="rechargeForm.rechargeCount" placeholder="请输入" style="width: 500px" />
        </el-form-item>
        <el-form-item v-else :label="rechargeTitle" prop="withdrawCount" required>
          <el-input v-model="rechargeForm.withdrawCount" placeholder="请输入" style="width: 500px" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="rechargeSubmit">确 定</el-button>
          <el-button @click="openrecharge = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!--  查看详情弹出框  -->
    <el-dialog title="查看详情" v-model="openDetail" width="700px" append-to-body @close="getList">
      <el-descriptions title="账号信息" :column="2" border>
        <el-descriptions-item label="账号ID">{{ detailData.userNo }}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{ detailData.mail }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ detailData.phone }}</el-descriptions-item>
        <el-descriptions-item label="昵称">{{ detailData.nickName }}</el-descriptions-item>
        <el-descriptions-item label="信用分">{{ detailData.creditScore }}</el-descriptions-item>
        <el-descriptions-item label="邀请码">{{ detailData.myInvitedCode }}</el-descriptions-item>

        <el-descriptions-item label="账号状态">
          <div v-if="detailData.status === 'Y'" style="color: rgba(14, 161, 82, 0.647058823529412)">
            {{ detailData.statusLabel }}
          </div>
          <div v-if="detailData.status === 'N'" style="color: rgba(217, 0, 27, 0.647058823529412)">
            {{ detailData.statusLabel }}
          </div>
        </el-descriptions-item>
        <el-descriptions-item label="是否在线">
          <div v-if="detailData.onine == false" style="color: #1890FF; width: auto;">离线</div>
          <div v-else style="color: #1890FF; width: auto;">在线</div>
        </el-descriptions-item>
        <el-descriptions-item label="注册时间">{{ detailData.createTime }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions title="推荐人信息" :column="2" border style="margin-top: 30px;" v-if="detailData.invitedId != ''">
        <el-descriptions-item label="账号ID">{{ detailData.agentVO.userNo }}</el-descriptions-item>
        <el-descriptions-item label="用户名">{{ detailData.agentVO.userName }}</el-descriptions-item>
        <el-descriptions-item label="姓名">{{ detailData.agentVO.nickName }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{ detailData.agentVO.phonenumber }}</el-descriptions-item>
        <el-descriptions-item label="邮箱">{{ detailData.agentVO.meail }}</el-descriptions-item>
      </el-descriptions>

      <el-descriptions title="账号信息" :column="3" border style="margin-top: 30px;">

        <el-descriptions-item label="USTD">{{ detailData.walletVO.walletAddress || 0 }}</el-descriptions-item>
        <el-descriptions-item label="BTC">{{ detailData.walletVO.btc || 0 }}</el-descriptions-item>
        <el-descriptions-item label="ETH">{{ detailData.walletVO.eth || 0 }}</el-descriptions-item>
        <el-descriptions-item label="ETH">{{ detailData.walletVO.eth || 0 }}</el-descriptions-item>
        <el-descriptions-item label="账户余额">{{ detailData.walletVO.balance || 0 }}</el-descriptions-item>
      </el-descriptions>
      <div style="margin-top: 10px;">
        <el-switch v-model="isLogin" active-color="#13ce66" v-hasPermi="['system:chatUser:edit']"
          inactive-color="#ff4949" inactive-text="允许登录" style="margin-right: 20px;" @change="istype"></el-switch>
        <el-switch v-model="isCashvalue" active-color="#13ce66" v-hasPermi="['system:chatUser:edit']"
          inactive-color="#ff4949" inactive-text="允许提现控制" style="margin-right: 20px;" @change="istype"></el-switch>
        <el-switch v-model="isMarketvalue" active-color="#13ce66" v-hasPermi="['system:chatUser:edit']"
          inactive-color="#ff4949" style="margin-right: 20px;" inactive-text="允许交易控制" @change="istype"></el-switch>
        <el-switch v-model="isStaff" active-color="#13ce66" v-hasPermi="['system:chatUser:edit']"
          inactive-color="#ff4949" style="margin-right: 20px;" inactive-text="是否为员工" @change="istype"></el-switch>
      </div>
      <!-- <el-row :gutter="20">

        <el-col :span="12" style="padding-left: 20px">
          <div style="padding-bottom: 10px"><span class="span-title">ID:</span>&emsp;{{ detailData.userNo }}</div>
          <div style="padding-bottom: 10px"><span class="span-title">编号:</span>&emsp;&emsp;{{}}</div>
          <div style="padding-bottom: 10px"><span class="span-title">手机号:</span>&emsp;&emsp;{{ detailData.phone }}
          </div>
          <div style="padding-bottom: 10px"><span class="span-title">昵称:</span>&emsp;&emsp;{{ detailData.nickName }}
          </div>
          <div style="padding-bottom: 10px"><span class="span-title">注册时间:</span>&emsp;&emsp;{{ detailData.createTime
            }}
          </div>
        </el-col>
      </el-row> -->
      <!-- <h3 style="font-weight: bold;color: #000;">账户信息</h3>
      <el-row :gutter="20">
        <el-col :span="24" style="padding-left: 20px">
          <div style="padding-bottom: 10px"><span class="span-title">账户余额:</span>&emsp;&emsp;{{
      detailData.walletVO.balance || 0 }}</div>
          <div style="padding-bottom: 10px"><span class="span-title">USTD:</span>&emsp;&emsp;{{}}</div>
          <div style="padding-bottom: 10px"><span class="span-title">BTC :</span>&emsp;&emsp;{{ detailData.walletVO.btc
      ||
      0 }}</div>
          <div style="padding-bottom: 10px"><span class="span-title">ETH :</span>&emsp;&emsp;{{ detailData.walletVO.eth
      ||
            0 }}</div>
        </el-col>
      </el-row> -->
    </el-dialog>
  </div>
</template>

<script setup name="User">
import { listUser, updateUser, editSwitch } from "@/api/boot/chatUser";
import { Picture as IconPicture } from '@element-plus/icons-vue'
import { downScore, upScore } from "@/api/boot/walletRechargeCash.js";
import { reactive, ref } from "vue";
import { checkPermi, checkRole } from "@/utils/permission";

const { proxy } = getCurrentInstance();

const userList = ref([]);
const open = ref(false);
const openDetail = ref(false);
const openrecharge = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const rechargeTitle = ref("");
const rechargeForm = ref({});
const permisson = ref({});
const checkAmount = (rule, value, callback) => {
  if (Number.parseFloat(value) <= 0) {
    return callback(new Error('操作额度必须大于0'))
  } else {
    return callback()
  }
}


const isCashvalue = ref(true)
const isMarketvalue = ref(true)
const isLogin = ref(true)
const isStaff = ref(0)
const value = ref()
const options = reactive([{ label: "USDT", value: "USDT" }, { label: "BTC", value: "BTC" }, { label: "ETH", value: "ETH" }])
const optiones = reactive([{ label: "安全", value: 0 }, { label: "正常", value: 1 }, { label: "风险", value: -1 }])

const data = reactive({
  detailData: {},
  form: {},
  queryParams: {
    current: 1,
    size: 10,
    userNo: null,
    mail: null,
    status: null,
    date: null,
  },
  rules: {}
});
const upDownData = reactive({
  upDownForm: {},
  upDownRules: {
    channel: [{ required: true, message: "请选择操作账户", trigger: "blur" }],
    risk: [{ required: true, message: "请选择操作账户", trigger: "blur" }],
    amount: [{ required: true, message: "请输入操作额度", trigger: "blur" },
    { pattern: /^\d+(\.\d+)?$/, message: "请输入数字", trigger: "blur" },
    { validator: checkAmount, trigger: "blur" },
    ],
  },
  upDownTitle: '',
  fxTitle: '',
  upDownOpen: false,
  downBalance: 0,
  selectedRow: null,
});


const { queryParams, form, rules, detailData } = toRefs(data);
const { upDownForm, upDownRules, upDownTitle, upDownOpen, downBalance, selectedRow } = toRefs(upDownData);

/** 查询用户管理列表 */
function getList() {
  loading.value = true;
  listUser(queryParams.value).then(response => {
    console.log(response.data.records)
    userList.value = response.data.records;
    total.value = response.data.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    userNo: null,
    phone: null,
    mail: null,
    nickName: null,
  };
  proxy.resetForm("userRef");
}

// 更多操作触发
function handleCommand(command, row) {
  switch (command) {
    case "handleUpScore":
      handleUpScore(row);
      break;
    case "handleDownScore":
      handleDownScore(row);
      break;
    case "handlfx":
      handlfx(row);
      break;
    default:
      break;
  }
}

function upDownReset(row) {
  upDownForm.value = {
    userId: row.userId,
    channel: null,
    amount: null,
    cashAddress: row.walletVO.walletAddress,
  };
  proxy.resetForm("upDownRef");
}

function upDownResets(row) {
  upDownForm.value = {
    userId: row.userId,
    channel: null,
    amount: null,
    cashAddress: row.walletVO.walletAddress,
  };
  proxy.resetForm("upDownRefs");
}

function upDownrecharge(row) {
  rechargeForm.value = {
    userNo: row.userNo,
    rechargeCount: null,
    withdrawCount: null,
  };
  proxy.resetForm("rechargeRef");
}

// 打开总充值|总提现模态框
function handlerecharge(row) {
  upDownrecharge(row)
  openrecharge.value = true
  if (row == 'rechargeCount') {
    rechargeTitle.value = '总充值'

  } else {
    rechargeTitle.value = '总提现'
  }
  console.log('123')
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.current = 1;
  getList();
}



/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

function viewDetail(row) {
  detailData.value = row;
  openDetail.value = true;
  if (detailData.value.isCash == 'Y') {
    isCashvalue.value = true
  } else {
    isCashvalue.value = false
  }


  if (detailData.value.isMarket == 'Y') {
    isMarketvalue.value = true
  } else {
    isMarketvalue.value = false
  }

  if (detailData.value.isLogin == 'Y') {
    isLogin.value = true
  } else {
    isLogin.value = false
  }

  if (detailData.value.isStaff == 1) {
    isStaff.value = true
  } else {
    isStaff.value = false
  }
}

/**
 * 冻结/解冻操作
 * @param row
 */
function handleStatus(row) {
  let title = row.status === 'Y' ? '冻结' : '解冻';
  let content = row.status === 'Y' ? '冻结后账户无法进行交易，是否确认操作？' : '解冻后账户恢复正常使用，是否确认操作？';
  const status = row.status === 'Y' ? 'N' : 'Y';

  proxy.$modal.confirm_tg(content, "确定" + title + "该账户？").then(function () {
    let data = {
      userNo: row.userNo,
      status: status,
      userId: row.userId,
    }

    return updateUser(data);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess(title + "成功");
  }).catch(() => {
  });
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  form.value.userNo = row.userNo;
  form.value.mail = row.mail;
  form.value.nickName = row.nickName;
  form.value.phone = row.phone;
  open.value = true;
  title.value = "修改基本信息";
}

/**
 * 上分按钮
 * @param row
 */
function handleUpScore(row) {
  upDownReset(row);
  upDownOpen.value = true;
  upDownTitle.value = "上分";
}

/**
 * 下分按钮
 * @param row
 */
function handleDownScore(row) {
  upDownReset(row);

  //downBalance.value = row.walletVO.amount;
  selectedRow.value = row;
  upDownOpen.value = true;
  upDownTitle.value = "下分";
}

function handlfx(row) {
  upDownReset(row);
  //downBalance.value = row.walletVO.amount;
  selectedRow.value = row;
  upDownOpen.value = true;
  upDownTitle.value = "风险";
}


/**
 * 操作状态改变
 */
function selHandleChannel(e) {

  if (e == 'USDT') {
    downBalance.value = selectedRow.value.walletVO.amount | 0;
  } else if (e == 'BTC') {
    downBalance.value = selectedRow.value.walletVO.btc | 0;
  } else if (e == 'ETH') {
    downBalance.value = selectedRow.value.walletVO.eth | 0;
  }
  // switch (e) {
  //   case 'USDT':
  //     downBalance.value = selectedRow.value.walletVO.amount | 0;
  //     break;
  //   case 'BTC':
  //     downBalance.value = selectedRow.value.walletVO.btc | 0;
  //     break;
  //   case 'ETH':
  //     downBalance.value = selectedRow.value.walletVO.eth | 0;
  //     break;
  //   default:
  //     break;
  // }
}

function allDownScore() {
  upDownForm.value.amount = downBalance.value;
}

/**
 * 上下分确认按钮
 */

 const open2 = () => {
  ElMessage({
    message: 'Congrats, this is a success message.',
    type: 'success',
  })
}

function upDownConSubmit() {
  proxy.$refs["upDownRef"].validate(valid => {
    if (valid) {
      if (upDownTitle.value === '上分') {
        upScore(upDownForm.value).then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess("操作成功");
          }
          upDownOpen.value = false;
        })
      } else if (upDownTitle.value === '下分') {
        downScore(upDownForm.value).then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess("操作成功");
          }
          upDownOpen.value = false;
        })
      } else if (upDownTitle.value === '风险') {
        let data = {
          userId: upDownForm.value.userId,
          risk: upDownForm.value.risk
        }
        editSwitch(data).then(res => {
          if (res.code === 200) {
            proxy.$modal.msgSuccess("操作成功");
          }
          upDownOpen.value = false;
        })
      } else {
        proxy.$modal.msgWarning("操作异常");
      }
    }
  })
}

function rechargeSubmit() {
  updateUser(form.value).then(response => {
    console.log(response)
    proxy.$modal.msgSuccess("修改成功");
    openrecharge.value = false
    getList();
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["userRef"].validate(valid => {
    if (valid) {
      if (form.value.userNo != null) {
        updateUser(form.value).then(response => {
          console.log(response)
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        proxy.$modal.msgWarning("页面异常,请刷新重试");
      }
    }
  });
}

//按钮控制集合
function istype() {

  let data = {
    userId: detailData.value.userId,
    isCash: isCashvalue.value ? 'Y' : 'N',
    isMarket: isMarketvalue.value ? 'Y' : 'N',
    isLogin: isLogin.value ? 'Y' : 'N',
    isStaff: isStaff.value ? 1 : 0,
  }
  editSwitch(data), then(res => {

  })
}

const pageChange = () => {
  loading.value = true;
  listUser(queryParams.value).then(response => {
    console.log(response)
    userList.value = response.data.records;
    total.value = response.data.total;
    loading.value = false;
  });
}

getList();
</script>

<style scoped>
.dialog-footer {
  text-align: center;
}

.el-button--small [class*=el-icon]+span {
  margin-left: 0px;
}
</style>
<style>
.el-table .cell {
  white-space: nowrap;
}

.el-button--small [class*=el-icon]+span {
  margin-left: 0px;
}

.span-title {
  font-size: 14px;
  font-family: "微软雅黑";
  color: #000;
  font-weight: bold;
}
</style>
